package com.ccys.cms.controller.productAndService;


import com.ccys.cms.service.productAndService.MedicalServiceTypeService;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.web.productAndService.NumEnum;
import com.ccys.db.entity.TblMedicalServiceType;
import com.ccys.db.vo.web.productAndService.MedicalServiceTypeVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/productAndService")
@Api(tags = "医疗服务类型")
public class MedicalServiceTypeController {

    @Resource
    private MedicalServiceTypeService service;


    @PostMapping("medicalServiceType")
    @ApiOperation("新增")
    @Transactional
    public ResponseResult insert(TblMedicalServiceType model) {

        int i = service.insertOrUpdate(model);
        return ResponseResult.update(i);
    }


    @PutMapping("medicalServiceType")
    @ApiOperation("修改")
    @Transactional
    public ResponseResult update(TblMedicalServiceType model) {

        int i = service.insertOrUpdate(model);
        return ResponseResult.update(i);
    }





    @DeleteMapping("medicalServiceType")
    @ApiOperation("根据Id删除")
    @Transactional
    public ResponseResult delete(String id) {

        TblMedicalServiceType model = new TblMedicalServiceType();
        model.setId(id);
        model.setDelFlag(NumEnum.DEL.getCode());
        int i = service.updateEntityById(model);
        return ResponseResult.update(i);
    }


    @GetMapping("medicalServiceType")
    @ApiOperation(value = "查询分页", notes = "排序字段 t1.status /t2. user_fullname / t1.created_on")
    public ResponseResult<PageInfo<MedicalServiceTypeVo>, Object> getPage() {

        return service.getPage();
    }

}
